<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center registers_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub registers_fd0_0'>
					<view class='flex flex-wrap align-center registers_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  registers_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<text class='registers_fd0_0_c1'>注册</text>
					<view class='flex flex-wrap align-center justify-end registers_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---logoflex布局开始-->
			<view class="flex flex-direction flex-wrap align-center justify-center benben-flex-layout registers_flex_1">
				<image class='registers_fd1_0' mode="aspectFill" src='/static/images/logo1.png'></image>
			</view>

			<!---logoflex布局结束-->
			<!---登录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout registers_flex_2">
				<view class='flex flex-wrap align-center registers_fd2_0'>
					<image class='registers_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"36.png"'></image>
					<benben-input class='flex-sub registers_fd2_0_c1' type="number" :placeholder="`请输入手机号`"
						confirm-type="done" :maxlength="11"
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="mobile" />
				</view>
				<view class='flex flex-wrap align-center registers_fd2_0'>
					<image class='registers_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"40.png"'></image>
					<benben-input class='flex-sub registers_fd2_0_c1' type="number" :placeholder="`请输入验证码`"
						confirm-type="done" :maxlength="4"
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="code" />
					<benben-send-verification-code key='1661226014418' ref="vCode1661226014418"
						class='registers_fd2_1_c2' after-text='后重新获取' before-text='获取验证码' type='1'
						:phone="mobile"></benben-send-verification-code>
				</view>
				<view class='flex flex-wrap align-center registers_fd2_0'>
					<image class='registers_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"37.png"'></image>
					<benben-flex-password-diy v-model="password"
						class-name="flex align-center flex-sub flex registers_fd2_2_c1"
						:placeholder="'请输入密码(6~12位字母+数字)'" :maxlength="12" :default-type='true'
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx">
						<template #show>
							<text class='fu-iconfont2  registers_fd2_2_c1_icon1' data-type="show">&#xE837;</text>
						</template>
						<template #hide>
							<text class='fu-iconfont2  registers_fd2_2_c1_icon2' data-type="hide">&#xEBCC;</text>
						</template>
					</benben-flex-password-diy>
				</view>
				<view class='flex align-center justify-center registers_fd2_3'>
					<button class='registers_fd2_3_c0' @tap.stop="registerFunc()">注册</button>
				</view>
				<view class='flex flex-wrap align-center justify-center registers_fd2_4'>
					<text>已有账号，前去</text>
					<text class='registers_fd2_4_c1' @tap.stop="handleJumpDiy" data-type="redirectTo"
						:data-url="`/pages/tabBar/logon/logon`">登录</text>
				</view>
			</view>

			<!---登录flex布局结束-->
			<view class="flex flex-direction align-center benben-position-layout flex registers_flex_3">
				<view class='flex flex-wrap align-center registers_fd3_0'>
					<benben-flex-switch-new class-name='flex flex registers_fd3_0_c0' v-model="check" :disabled='false'>
						<template v-slot:checked>

							<view class='flex flex position-relative align-center'>
								<image class='registers_checkfd3_0_c0_c0_c0' mode="aspectFit"
									:src='STATIC_URL+"117.png"'></image>
							</view>

						</template>
						<template v-slot:unchecked>

							<view class='flex flex position-relative justify-end align-center'>
								<image class='registers_checkfd3_0_c0_c0_c0' mode="aspectFit"
									:src='STATIC_URL+"49.png"'></image>
							</view>

						</template>
					</benben-flex-switch-new>
					<text class='registers_fd3_0_c1'>已阅读并同意</text>
					<text class='registers_fd3_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/agreements/agreements?type=19`">《用户协议》</text>
					<text class='registers_fd3_0_c1'>与</text>
					<text class='registers_fd3_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/agreements/agreements?type=18`">《隐私政策》</text>
				</view>

			</view>
			<view :style="{height: '300rpx'}"></view>


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"mobile": "",
				"code": "",
				"password": "",
				"invite_code": "",
				"data": {
					"userinfo": {
						"user_token": "",
						"id": "",
						"account": "",
						"avatar": "",
						"real_name": "",
						"nickname": "",
						"email": "",
						"gender": "",
						"mobile": "",
						"birthday": "",
						"client_id": "",
						"phone": "",
						"user_type": "",
						"certified_status": ""
					}
				},
				"check": false
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			/**
			 * @returns 
			 * Android       安卓
			 * IOS       苹果
			 * Web       H5 或 pc
			 * Wechat       微信小程序
			 * Alipay       支付宝小程序
			 * Baidu       百度小程序
			 * ByteBounce       抖音小程序
			 * 360       360小程序
			 * FastApp       快应用
			 */
			appSystemIdentification() {
				return this.$store.state.appSystemIdentification
			}
		},
		watch: {},
		onLoad(options) {

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//注册
			async registerFunc() {
				if (!validate(this.mobile, 'require')) {
					this.$message.info('手机号不能为空');
					return false;
				}
				if (!validate(this.mobile, 'phone')) {
					this.$message.info('请输入正确的手机号');
					return false;
				}
				if (!validate(this.code, 'require')) {
					this.$message.info('验证码不能为空');
					return false;
				}
				if (!validate(this.code, 'captcha')) {
					this.$message.info('请输入正确的验证码');
					return false;
				}
				if (!validate(this.password, 'require')) {
					this.$message.info('请输入密码(6~12位字母+数字)');
					return false;
				}
				if (!validate(this.password, 'password')) {
					this.$message.info('请输入正确密码(6~12位字母+数字)');
					return false;
				}
				if (this.check === false) {
					this.$message.info('请先阅读并同意《用户协议》与《隐私政策》');
					return false;
				}
				//请求方法
				//数据验证

				let datadata = await this.$api.dbPost(global.apiUrls.post5cad9f63e4f94, {
					mobile: this.mobile,
					code: this.code,
					type: '1',
					password: this.password,
					user_type: '2'
				});
				if (!datadata) return
				if (datadata.data.code != 1) {
					this.$message.info(datadata.data.msg);
					return
				}
				let infodata = datadata.data;
				this.data = infodata.data

				this.$store.commit('saveToken', this.data.userinfo.user_token)
				this.$store.commit('updateUserInfo', this.data.userinfo)
				this.getClient()
				this.$urouter.redirectTo(`/pages/login/improveData/improveData`);
			},
			//消息推送
			getClient() {
				/* 获取设备ID用作消息推送 start */
				// #ifdef APP-PLUS
				let client_id = plus.push.getClientInfo().clientid;
				console.log('设备client_id：' + client_id);
				if (client_id) {
					this.$api.post(global.apiUrls.post6655424618774, {
							client_id: client_id,
							client_type: this.appSystemIdentification == 'Android' ? 1 : 2
						})
						.then(result => {
							console.log('设备储存', result);
						});
				}
				// #endif
				/* 获取设备ID end */
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(255, 255, 255, 1);
		background-size: 100% auto;
	}

	.registers_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.registers_fd0_0_c1 {
		font-size: 36rpx;
		font-weight: 700;
		color: #333333;
		line-height: 50rpx;
	}

	.registers_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.registers_fd0_0_c0 {
		width: 120rpx;
		height: 88rpx;
	}

	.registers_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.registers_flex_1 {
		padding: 110rpx 24rpx 80rpx 24rpx;
	}

	.registers_fd1_0 {
		width: 510rpx;
		height: 150rpx;
	}

	.registers_flex_2 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.registers_fd2_4_c1 {
		color: var(--benbenFontColor4);
		margin: 0rpx 0rpx 0rpx 2rpx;
	}

	.registers_fd2_4 {
		margin: 32rpx 0rpx 0rpx 0rpx;
	}

	.registers_fd2_3_c0 {
		background: rgba(48, 144, 255, 1);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		height: 80rpx;
		line-height: 80rpx;
		font-weight: 500;
		width: 638rpx;
	}

	.registers_fd2_3 {
		margin: 94rpx 0rpx 0rpx 0rpx;
	}

	.registers_fd2_2_c1_icon2 {
		text-align: center;
		font-size: 44rpx;
	}

	.registers_fd2_2_c1_icon1 {
		text-align: center;
		font-size: 44rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
	}

	::v-deep .registers_fd2_2_c1 {
		font-size: 32rpx;
		color: #333;
		font-weight: 400;
		width: 620rpx;
	}

	.registers_fd2_1_c2 {
		font-size: 28rpx;
		font-weight: 400;
		color: #57AEFB;
		line-height: 40rpx;
	}

	.registers_fd2_0_c1 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
	}

	.registers_fd2_0_c0 {
		width: 34rpx;
		height: 34rpx;
		margin: 0rpx 28rpx 0rpx 0rpx;
	}

	.registers_fd2_0 {
		border-bottom: 1px solid #eee;
		padding: 40rpx 0rpx 40rpx 0rpx;
	}

	.registers_flex_3 {
		width: 750rpx;
		height: 300rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
	}

	.registers_fd3_0_c2 {
		line-height: 32rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #3090FF;
	}

	.registers_fd3_0_c1 {
		line-height: 32rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
	}

	.registers_checkfd3_0_c0_c0_c0 {
		width: 24rpx;
		height: 24rpx;
	}

	::v-deep .registers_fd3_0_c0 {
		margin: 0rpx 8rpx 0rpx 0rpx;
	}

	.registers_fd3_0 {
		margin: auto 0rpx 32rpx 0rpx;
	}
</style>